/*-------------------------------------------------------------------------*/
/**
  @file		jostle_struct.h
  @author	Renaud Wanschoor
  @date	july 2004
  @version	$Revision: 2.2 $
  @brief	specific jostle structure used by pagridplot
  
*/
/*--------------------------------------------------------------------------*/
#ifndef JOSTLE_STRUCT_H
#define JOSTLE_STRUCT_H

struct  jostlegraphdef {
  /**********************
   * graph information
   *********************/
  int *gdata;           /* pointer where memory is allocated */

  int wgtflag;		/* whether the vertics are weighted*/
  int ncon;		/* The # of constrains */ 
  int nvtxs, nedges;	/* The # of vertices and edges in the graph */
  int maxdeg;		/* maximum degree of a vertex */
  int *adjidx;		/* Pointers to the locally stored vertices */
  int *vwgt;		/* Vertex weights */
  int *adjncy;		/* adjacency lists of nvtxs */
  int *adjwgt;		/* weights of the adjacency lists */
  int *adjwgtsum;	/* The sum of the adjacency weight of each vertex */
  
  /***********************
   * Matching information
   **********************/
  /* memory is allocated in gdata */
  int *match;		/* label with which a vertex is matched */
  int *map;		/* label in the coarser graph */

  /**************************
   * Refinement information
   *************************/
  int *pro;		/* Array holding the assigned processor to a vertex*/

  /* Additional info needed by the MOC routines */
  float *nvwgt;		/* Normalized vertex weights */
  float *npwgts;	/* The normalized partition weights */
  
  /*Boundary Information*/
  int *bndvtx;		/* holding the lables of boundary vertices */
  int *bndptr;		/* pointers for bndvtx: -1:non-boundary vertex */
  int nbnd;		/* number of boundary vertices */
  
  /**************************
   * level browsing
   *************************/
  struct jostlegraphdef *child;		/* pointer to child (coarser) graph */
  struct jostlegraphdef *father;	/* pointer to father (finer) graph */
};
typedef struct jostlegraphdef JostleGraphType;

/*************************************************************************
 * The following data structure stores processors info
 ************************************************************************/
struct jostleadjprolist{
  int destination; 		/*processor that connects*/
  int weight;      		/*weight of link connecting two processors*/
};
typedef struct jostleadjprolist JostleAdjProList;

struct jostleadjacentpro{ 
  int count;	    		/*number of adjacent processors*/
  JostleAdjProList *list; 	
};

typedef struct jostleadjacentpro JostleAdjacentPro;


/*************************************************************************
 * The following data structure stores grid information 
 ************************************************************************/
struct jostlegriddef {		/*computationtional grid information*/
  int npro;			/*Number of processors*/
  int nedges;			/*Number of links*/

  double **ratio;		/*Ratio (Tcomm/Tcomp) matrix*/

  int*    gdata;		/* pointer to allocated memory */
  int*    adjidx;		/* edge indexes */ 
  int*    adjncy;		/* edges (destination processor) */
  int*    adjwgt;		/* edges weight */
  double* exec;                 /* array of processors execution time */
  
   /**********************************/
  /* initial values of the ratio    */
  /**********************************/

  int     r_from;
  int     r_to;
  double  r_val;

  /**********************************/
  /*    connectivity of processor   */
  /*    in the application graph    */
  /**********************************/

  int*             rpro;		
  JostleGraphType* app;		

  /**********************************/
  /* for network flow calculations  */
  /**********************************/
  
  double *fdata;
  double *b;
  double *r;
  double *p;
  double *w;
  double *x;
  double *flow;

  /** -- REMOVE -- **/
  int **realnetcost;		/*Real Network Cost matrix*/
  int **netcost;		/*matrix that is used in refinement*/
  double *proratio;		/*Execution time Ratio for each processors*/
  double *proportion;		/*Processor weighting for each processors*/
  double *prospeed;             /* 1/proportion */
  int *penalty;			/*penalty weight for each processors*/
  JostleAdjacentPro* adjpro;	/*Processor Adjacent Info*/
  /** -- END REMOVE -- **/

  int maxdegree;		/*average degree to processor graph*/
};
typedef struct jostlegriddef JostleGridType;

#endif
